package com.kujie.access.domain.vo;

import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.kujie.common.core.validate.EditGroup;
import com.kujie.access.domain.po.PropertyListManagement;
import com.kujie.access.domain.po.RegionManagement;
import com.kujie.common.excel.annotation.ExcelDictFormat;
import com.kujie.common.excel.convert.ExcelDictConvert;
import io.github.linpeilie.annotations.AutoMapper;
import jakarta.validation.constraints.NotNull;
import lombok.Data;

import java.io.Serial;
import java.io.Serializable;
import java.util.Date;
import java.util.Map;

@Data
@AutoMapper(target = PropertyListManagement.class)
public class PropertyListManageVO implements Serializable {
    @Serial
    private static final long serialVersionUID = 1L;

    /**
     * id
     */
    @ExcelIgnore
    @NotNull(message = "id不能为空", groups = {EditGroup.class})
    private Long id;

    /**
     * 所属区域
     */
    @ExcelProperty(value = "所属区域（请按照现有的区域填写例如：A塔，B塔）")
    private String belongArea;

    /**
     * access_region_management表中的index_code
     */
    @ExcelIgnore
    private String indexCode;

    /**
     * 房源房号
     */
    @ExcelProperty(value = "房源房号")
    private String roomNumber;

    /**
     * 房源面积，单位平方米
     */
    @ExcelProperty(value = "房源面积，单位平方米")
    private String area;

//    /**
//     * 房源户型
//     */
//    @ExcelProperty(value = "房源户型")
//    private String houseType;

    /**
     * 房源租赁状态(空置、已租、已售出、装修中、预定)
     */
    @ExcelProperty(value = "房源租赁状态", converter = ExcelDictConvert.class)
    @ExcelDictFormat(dictType = "lease_type")
    private String leaseType;

    /**
     * 房源租赁用途(商业、办公等)
     */
    @ExcelProperty(value = "房源租赁用途")
    private String purpose;

//    /**
//     * 房源朝向
//     */
//    @ExcelProperty(value = "房源朝向")
//    private String propertyOrientation;

    /**
     * 配套设施
     */
    @ExcelProperty(value = "配套设施")
    private String supportFacilities;

    /**
     * 租金以平方米的价格为单位
     */
    @ExcelProperty(value = "租金（元）")
    private String rent;

    /**
     * 房源售价
     */
    @ExcelProperty(value = "房源售价（元）")
    private String price;

    /**
     * 房源平面图
     */
    @ExcelIgnore
    private String floorPlan;

    /**
     * 这条数据是否被处理过
     */
    @ExcelIgnore
    private Boolean isProcessed = false;

    /**
     * 创建时间
     */
    @ExcelIgnore
    private Date createTime;

    public PropertyListManageVO() {

    }

    public PropertyListManageVO(Long id, String indexCode, String roomNumber, String area, String leaseType, String purpose, String supportFacilities, String rent, String price, String floorPlan, Map<String, RegionManagement> regionUuidToRegionManagement) {
        RegionManagement regionManagement = regionUuidToRegionManagement.get(indexCode);
        this.id = id;
        this.belongArea = regionManagement.getName();
        this.indexCode = indexCode;
        this.roomNumber = roomNumber;
        this.area = area;
//        this.houseType = houseType;
        this.leaseType = leaseType;
        this.purpose = purpose;
//        this.propertyOrientation = propertyOrientation;
        this.supportFacilities = supportFacilities;
        this.rent = rent;
        this.price = price;
        this.floorPlan = floorPlan;
        this.createTime = regionManagement.getCreateTime();
    }
}
